import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
import org.junit.Test;

import java.io.IOException;
import java.net.URISyntaxException;

public class 测试改写器 {
    
    @Test
    public void 测试() throws IOException, URISyntaxException {
        var 路径 = Tools.getResourcePath("t.cymbol");
        var 源文件 = Tools.读文件(路径);

        var input = CharStreams.fromString(源文件);
        var lexer = new CymbolLexer(input);// 词法分析器，将输入文本转换为词法符号
        var tokens = new CommonTokenStream(lexer);// 词法符号流
        var parser = new CymbolParser(tokens);// 语法分析器
        
        var 改写器 = new Cymbol语言改写器(tokens);
        new ParseTreeWalker().walk(改写器, parser.compilationUnit());
        System.out.println(改写器.取改写后结果());
    }
    
    
}
